<template>
  <div>
      学校列表
      <table border="1">
        <tr>
            <th>编号</th>
            <th>学校名字</th>
            <th>操作</th>
        </tr>
        <tr v-for="(school,index) in schoolList" :key="index">
            <td>{{school.id}}</td>
            <td>{{school.schoolName}}</td>
            <td></td>
        </tr>

      </table>    
  </div>
</template>

<script>
export default {
    data() {
        //必须要有返回值
        return {
            schoolList:[]
        }
    },
    methods: {
        init(){
            //写法一
            this.$http.get('/school/all').then(res=>{

            })
        },
        //是ES8提供的语法，借助babel转化成js认识的语法
        async initSchoolList(){
            //写法二
            let res = await this.$http.get('/school/all')
            console.log(res)
            this.schoolList = res.data.data
        }
    },
    created() {
        this.initSchoolList()
    },
}
</script>

<style>

</style>